using Application.Abstractions.Messaging;
using Domain.Todos.Events;
using Microsoft.Extensions.Logging;

namespace Application.Todos.Create;

/// <summary>
/// 待办事项创建事件处理器
/// </summary>
public sealed class TodoItemCreatedEventHandler(ILogger<TodoItemCreatedEventHandler> logger)
    : DomainEventHandler<TodoItemCreatedEvent>
{
    public override async ValueTask Handle(TodoItemCreatedEvent notification, CancellationToken cancellationToken = default)
    {
        logger.LogInformation(
            "用户 {UserId} 创建了新的待办事项: {Description} (优先级: {Priority})",
            notification.UserId,
            notification.Description,
            notification.Priority);

        // 这里可以添加其他业务逻辑，比如：
        // - 发送通知
        // - 更新统计数据
        // - 记录审计日志
        // - 触发其他业务流程

        await Task.CompletedTask;
    }
}
